<template>
  <div :key="key">
    <center>
      <h3>南京市养老机构综合运营补贴申请表</h3>
    </center>
    <table border="1" cellpadding="5" cellspacing="0" width="100%" class="table1">
        <caption colspan="4">（所属时间： {{data.applyYear|| ' '}}年第{{data.applyQuarterLabel|| ' '}}季度）</caption>
      <!-- 基本情况 -->
        <caption>基本情况</caption>
      <tr>
        <td width="15%">机构名称</td>
        <td >{{ data.organizationName }}</td>
        <td width="15%">法人代表人</td>
        <td>{{ data.deputyUserName }}</td>
      </tr>
      <tr>
        <td>机构地址</td>
        <td>{{ data.organizationAddress }}</td>
        <td>联系电话</td>
        <td>{{ data.deputyUserPhone }}</td>
      </tr>
      <tr>
        <td>机构等级</td>
        <td>{{ data.organizationLevelLabel }}</td>
        <td>营业执照（民非）证号</td>
        <td>{{ data.organizationLicense }}</td>
      </tr>
      <tr>
        
        <td>机构设置证号（备案）</td>
        <td>{{data.organizationFiling }}</td>
        <td>开户银行</td>
        <td>{{ data.bankName }}</td>
      </tr>
      <tr>
        
        <td>银行账号</td>
        <td colspan="3">{{ data.bankAccount }}</td>
      </tr>
      <tr>
        <td>养老机构服务质量大检查指南基础指标是否全部达标</td>
        <td colspan="3">{{ data.baseQualityStandardLabel }}</td>
      </tr>
    </table>
    <br/>
    <!-- 员工概括 -->
    <table border="1" cellpadding="5" cellspacing="0"  width="100%" class="table2">
        <caption colspan="8">员工概括</caption>
        <tr>
          <td>员工总数</td>
          <td>{{data.staffNum }}</td>
          <td>持证人数</td>
          <td>{{data.certStaffNum }}</td>
          <td>管理人员</td>
          <td>{{ data.managerNum }}</td>
          <td>持证人数</td>
          <td>{{ data.certManagerNum }}</td>
        </tr>
    </table>
    <br/>
    <!-- 申请内容 -->
    <table border="1" cellpadding="5" cellspacing="0"  width="100%">
          <caption colspan="10">申请内容</caption>
        <tr>
          <th rowspan="2">月份</th>
          <th rowspan="2">机构等级</th>
          <th colspan="2">介助</th>
          <th colspan="2">介护</th>
          <th rowspan="2">基准补贴总金额</th>
          <th rowspan="2">等级系数</th>
          <th rowspan="2">基准总金额x等级系数</th>
        </tr>
        <tr>
          <th>人数</th>
          <th>金额</th>
          <th>人数</th>
          <th>金额</th>
        </tr>
        <tr v-for="(item,index) in applyData" :key="index">
          <th>{{ item.belongYearMonth }}月份</th>
          <td>{{ data.organizationLevelLabel }}</td>
          <td>{{ item.assistNum ||'0' }}</td>
          <td>{{ item.assistAmount.toFixed(2)||'0.00' }}</td>
          <td>{{ item.careNum ||'0'}}</td>
          <td>{{item.careAmount.toFixed(2)||'0.00' }}</td>
          <td>{{ item.baseSubsidyTotalAmount.toFixed(2)||'0.00' }}</td>
          <td>{{ item.levelFactor.toFixed(2)||'0.00' }}</td>
          <td>{{item.baseSubtotal.toFixed(2)||'0.00' }}</td>
        </tr>
        <tr>
          <th colspan="2">总计</th>
          <td>{{ columnSum('assistNum') }}</td>
          <td>{{ columnSum('assistAmount').toFixed(2)||'0.00' }}</td>
          <td>{{ columnSum('careNum') }}</td>
          <td>{{ columnSum('careAmount').toFixed(2)||'0.00' }}</td>
          <td>{{ columnSum('baseSubsidyTotalAmount').toFixed(2)||'0.00' }}</td>
          <td>{{ columnSum('levelFactor').toFixed(2)||'0.00' }}</td>
          <td>{{ columnSum('baseSubtotal').toFixed(2)||'0.00' }}</td>
        </tr>
        <tr>
            <th>申请金额</th>
            <td colspan="3">{{ data.applyAmount }}</td>
            <th>申请金额（大写）</th>
            <td colspan="4"></td>
          </tr>
          <tr>
            <th colspan="9">本机构承诺以上及所附数据资料真实有效，如有不实，愿承担相关处罚。</th>
          </tr>
          <tr>
            <th colspan="9">负责人签名：                 （单位盖章）</th>
          </tr>
          <tr>
            <th colspan="9">{{ handleDate(data.applyDate) }}</th>
          </tr>
    </table>
    <br/>
    <!-- 审核意见 -->
    <table border="1" cellpadding="5" cellspacing="0"  width="100%">
      <caption>审核意见</caption>
      <tr>
        <th rowspan="2">区民政部门意见</th>
        <td rowspan="2" style="width: 30%;">{{data.areaCivilAffairNote}}</td>
        <th>区民政局：                 （章）</th>
      </tr>
      <tr>
        <th>{{ handleDate(data.civilApprovalDate) }}</th>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'
type Props = {
  nowRowData?: any,
}
const props = withDefaults(defineProps<Props>(), {
  nowRowData: {}
})
let data:any = {}
data = props.nowRowData
let applyData:any = ref({})

let key = ref(1)
// 获取申请数据
const getApplyData = (id) => {
  apiMod.dpOrgOperateApply_page({headId:id,pageParaPO:{"size":100000,"current":1}}).then(res=>{
    applyData.value = res.data.records
    key.value = Math.random()
  })
}
getApplyData(props.nowRowData.soleValue)

// 列统计
const columnSum = (prop)=> {
  let sum = 0
  if(prop && applyData.value.length>0){
    applyData.value.forEach(el => {
      if(el[prop]){
        sum+=el[prop]
      }
    });
  }
  return sum
}

// 处理时间，年月日
const handleDate = (date) =>{
  if(date){
    let dateList = date.split('-')
    return dateList[0]+'年'+dateList[1]+'月'+dateList[2]+'日'
  }else{
    return '年 月 日'
  }
}
</script>
<style scoped lang="scss">
.table1>tr>td:nth-child(odd) {
  font-weight: 700;
}

.table2>tr>td:nth-child(odd) {
  font-weight: 700;
}
</style>